local ads__jingxin = fk.CreateSkill{
  name = "ads__jingxin",
}
ads__jingxin:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(ads__jingxin.name) then return false end
    
    local cardCount = 0
    for _, move in ipairs(data) do
      if move.to and move.to == player and move.toArea == Card.PlayerHand then
        cardCount = cardCount + #move.moveInfo
      end
    end
    
    return cardCount > 0
  end,
  on_trigger = function(self, event, target, player, data)
    local cardCount = 0
    for _, move in ipairs(data) do
      if move.to and move.to == player and move.toArea == Card.PlayerHand then
        cardCount = cardCount + #move.moveInfo
      end
    end
    
    for i = 1, cardCount do
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return player:compareDistance(p, 1, "<=")
    end)
    if #targets == 0 then return false end
    
    local selected = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#ads__jingxin-choose",
      skill_name = ads__jingxin.name,
      cancelable = true
    })
    if selected and #selected > 0 then
      event:setCostData(self, {target = selected[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event:getCostData(self).target
    room:damage({
      from = player,
      to = target,
      damage = 1,
      skillName = ads__jingxin.name
    })
  end,
})
ads__jingxin:addEffect(fk.DrawInitialCards, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(ads__jingxin.name) and target == player
  end,
  on_trigger = function(self, event, target, player, data)
    self:doCost(event, target, player, data)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return player:compareDistance(p, 1, "<=")
    end)
    if #targets == 0 then return false end
    
    local selected = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#ads__jingxin-choose",
      skill_name = ads__jingxin.name,
      cancelable = true
    })
    if selected and #selected > 0 then
      event:setCostData(self, {target = selected[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event:getCostData(self).target
    room:damage({
      from = player,
      to = target,
      damage = 1,
      skillName = ads__jingxin.name
    })
  end,
})

ads__jingxin:addEffect(fk.AfterDrawInitialCards, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(ads__jingxin.name) and target == player
  end,
  on_trigger = function(self, event, target, player, data)
    for i = 1, data.num do
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return player:compareDistance(p, 1, "<=")
    end)
    if #targets == 0 then return false end
    
    local selected = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#ads__jingxin-choose",
      skill_name = ads__jingxin.name,
      cancelable = true
    })
    if selected and #selected > 0 then
      event:setCostData(self, {target = selected[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event:getCostData(self).target
    room:damage({
      from = player,
      to = target,
      damage = 1,
      skillName = ads__jingxin.name
    })
  end,
})

ads__jingxin:addEffect(fk.HpRecover, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(ads__jingxin.name) and target == player
  end,
  on_trigger = function(self, event, target, player, data)
    self:doCost(event, target, player, data)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return player:compareDistance(p, 1, "<=")
    end)
    if #targets == 0 then return false end
    
    local selected = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#ads__jingxin-choose",
      skill_name = ads__jingxin.name,
      cancelable = true
    })
    if selected and #selected > 0 then
      event:setCostData(self, {target = selected[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event:getCostData(self).target
    room:damage({
      from = player,
      to = target,
      damage = 1,
      skillName = ads__jingxin.name
    })
  end,
})




Fk:loadTranslationTable{
  ["ads__jingxin"] = "静心",
  [":ads__jingxin"] = "当你获得一张牌或回复一点体力时，你可以对距离1以内的角色造成1点伤害。",
  ["#ads__jingxin-choose"] = "静心：你可以对一名距离1以内的角色造成1点伤害",
  ["$ads__jingxin1"] = "哈哈哈哈哈哈，赢你还不容易？",
  ["$ads__jingxin2"] = "哼！也不看看我是何人！",
}

return ads__jingxin
